#ifndef _I3_SERVER_PKT_H
#define _I3_SERVER_PKT_H

#ifndef __RTTI
#define __RTTI
#endif

void send_opt_trigger_not_present(srv_context *ctx, ID *id, 
				  i3_addr *to, int sfd);
void send_opt_ratelimit_exceeded(srv_context *ctx, ID *id, 
				 i3_addr *to, int sfd);
void send_opt_cache_address(srv_context *ctx, ID *id, int prefix_len, 
			    i3_addr *to, int sfd);
void send_opt_cache_dest_address(srv_context *ctx, i3_trigger *tr, 
				 int prefix_len, 
				 i3_addr *to, int sfd);
void send_trigger_reply(srv_context *ctx, 
			void * __RTTI *tarray, char *opt_type_array, 
			int tnum, i3_addr *to, int sfd);

void forward_packet_ip(srv_context *ctx, 
		       i3_header *hdr, int header_room, 
		       char *payload, int payload_len,
		       i3_addr *to, int to_end_host);
void forward_packet_chord(i3_header *hdr, char *payload, int payload_len);
void forward_packet_i3(srv_context *ctx, 
		       i3_header *hdr, int header_room, 
		       char *payload, int payload_len,
		       trigger_node *t_node);


int is_sender_natted(i3_header *hdr, struct sockaddr_in* real_addr);
int is_exit_i3srv(i3_header *hdr);
i3_addr *translate_ipv4nat_to_ipv4(srv_context *ctx, 
				   i3_addr *sender_addr);
i3_addr *translate_ipv4_to_ipv4nat(srv_context *ctx, 
				   i3_addr *sender_addr,
				   struct sockaddr_in* real_addr);
void translate_hdr_options_in(srv_context *ctx, 
			      i3_header *hdr, uint8_t flag_tcp,
			      struct sockaddr_in* real_addr);
void translate_hdr_options_out(srv_context *ctx, 
			       i3_header *hdr, 
			       struct sockaddr_in* dst_addr);

#endif
